#pragma once
#include <iostream>
#include <vector>
#include <list>
#include "list.h"
//using namespace std;


//void test1()
//{
//	MyList::list_node<int> node0(0);
//	MyList::list_node<int> node1(1);
//	MyList::list_node<int> node2(2);
//	MyList::list_node<int> node3(3);
//	MyList::list_node<int> node4(4);
//	std::cout << *(node0._data) << std::endl;
//	std::cout << *(node1._data) << std::endl;
//	std::cout << *(node2._data) << std::endl;
//	std::cout << *(node3._data) << std::endl;
//	std::cout << *(node4._data) << std::endl;
//}

void test2()
{
	MyList::List<int> list1(0);
	list1._push_front(1);
	list1._push_front(2);
	list1._push_front(3);
	list1._push_front(4);
	list1._push_front(5);
	list1._push_back(-1);
	list1._push_back(-2);
	list1._push_back(-3);
	list1._push_back(-4);
	list1._push_back(-5);
	list1._pop_back();
	list1._pop_back();
	list1._pop_front();
	list1._pop_front();
}

void test3()
{
	MyList::List<int> list1(0);
	list1._push_front(1);
	list1._push_front(2);
	list1._push_front(3);
	list1._push_front(4);
	list1._push_front(5);
	list1._push_back(-1);
	list1._push_back(-2);
	list1._push_back(-3);
	list1._push_back(-4);
	list1._push_back(-5);

	typename MyList::List<int>::iterator it = list1.begin();
	while (it != list1.end())
	{
		std::cout << (*it) << ' ';
		(*it) += 10;
		std::cout <<(*it++)<<"    ";

	}
	std::cout << std::endl;
	for (auto i : list1)
	{
		std::cout << i << " ";
	}
	std::cout << std::endl;
}
void test4()
{
	MyList::List<int> list1(0);
	list1._push_front(1);
	list1._push_front(2);
	list1._push_front(3);
	list1._push_front(4);
	list1._push_front(5);
	list1._push_back(-1);
	list1._push_back(-2);
	list1._push_back(-3);
	list1._push_back(-4);
	list1._push_back(-5);
	for (auto i : list1)
	{
		std::cout << i << " ";
	}
	std::cout << std::endl;
	typename MyList::List<int>::iterator it = list1.begin();
	++it;
	++it;
	++it;
	list1.insert(it, 100);
	for (auto i : list1)
	{
		std::cout << i << " ";
	}
	std::cout << std::endl;
	++it;
	++it;
	++it;
	list1.erase(it);
	for (auto i : list1)
	{
		std::cout << i << " ";
	}
	std::cout << std::endl;
}
void test5()
{
	MyList::List<int> list1(0);
	list1._push_front(1);
	list1._push_front(2);
	list1._push_front(3);
	list1._push_front(4);
	list1._push_front(5);
	list1._push_back(-1);
	list1._push_back(-2);
	list1._push_back(-3);
	list1._push_back(-4);
	list1._push_back(-5);
	for (auto i : list1)
	{
		std::cout << i << " ";
	}
	std::cout << std::endl;
	typename MyList::List<int>::iterator it = list1.begin();
	++it;
	++it;
	++it;
	typename MyList::List<int>::iterator it2 = list1.end();
	--it2;
	--it2;
	--it2;
	MyList::List<int> list2(it,it2);
	for (auto i : list2)
	{
		std::cout << i << " ";
	}
	std::cout << std::endl;
	printContainer(list1);
}
struct AA
{
	int a1;
	int a2;
};
void test6()
{
	MyList::List<AA> list1;
	list1._push_front({ 1,21 });
	list1._push_front({ 2,22 });
	list1._push_front({ 3,23 });
	list1._push_front({ 4,24 });
	list1._push_front({ 5,25 });
	for (auto i : list1)
	{
		std::cout << i.a1 << " ";
		std::cout << i.a2 << " ";
	}
	std::cout << std::endl;
	typename MyList::List<AA>::iterator it = list1.begin();
	++it;
	++it;
	++it;
	typename MyList::List<AA>::iterator it2 = list1.end();
	--it2;
	--it2;
	--it2;
	std::cout << it.operator->()->a1 << ' ' << it->a2 << std::endl;
}
void test7()
{
	MyList::List<int> list1(0);
	list1._push_front(1);
	list1._push_front(2);
	list1._push_front(3);
	list1._push_front(4);
	list1._push_front(5);
	list1._push_back(-1);
	list1._push_back(-2);
	list1._push_back(-3);
	list1._push_back(-4);
	list1._push_back(-5);
	MyList::printlist(list1);
	typename MyList::List<int>::iterator it = list1.begin();
	while (it != list1.end())
	{
		if (*it == 3 || *it == -3)
		{
			it = list1.erase(it);
		}
		else
		{
			it++;
		}
	}
	MyList::printContainer(list1);
	list1.clear();
	MyList::printContainer(list1);
	std::cout << list1.empty() << std::endl;
}
void test8()
{
	MyList::List<int> list1(0);
	list1._push_front(1);
	list1._push_front(2);
	list1._push_front(3);
	list1._push_front(4);
	list1._push_front(5);
	list1._push_back(-1);
	list1._push_back(-2);
	list1._push_back(-3);
	list1._push_back(-4);
	list1._push_back(-5);
	MyList::printlist(list1);
	MyList::List<int> list2(list1);
	MyList::printlist(list2);
	list2.clear();
	MyList::printlist(list2);
	list2 = list1;
	MyList::printlist(list2);
	MyList::List<int> list3 = { 0,1,2,3,4,5,6 };
	//std::list<int> list3={0,1,2,3,4,5,6};
	MyList::printContainer(list3);


}

void test9()
{
	MyList::List<int> list1(0);
	list1._push_front(1);
	list1._push_front(2);
	list1._push_front(3);
	list1._push_front(4);
	list1._push_front(5);
	list1._push_back(-1);
	list1._push_back(-2);
	list1._push_back(-3);
	list1._push_back(-4);
	list1._push_back(-5);

	typename MyList::List<int>::iterator it = list1.begin();
	while (it != list1.end())
	{
		std::cout << *it << ' ';
		++it;
	}
	std::cout << std::endl;

	typename MyList::List<int>::reverse_iterator rit = list1.rbegin();
	while (rit != list1.rend())
	{
		std::cout << *rit << ' ';
		++rit;
	}
	std::cout << std::endl;
}
int main()
{
	//test8();
	test9();
	return 0;
}